local zhengrong = fk.CreateSkill {
  name = "tyj_heg__zhengrong",
}

Fk:loadTranslationTable {
  ["tyj_heg__zhengrong"] = "征荣",
  [":tyj_heg__zhengrong"] = "每回合限一次，当你对其他角色造成伤害时，你可以将其场上的一张牌移动至你的对应区域内或弃置之。",
  ["tyj_heg__zhengrong_discard"] = "弃置其场上的一张牌",
  ["tyj_heg__zhengrong_move"] = "将其场上一张牌移动至你的区域内",
  ["$tyj_heg__zhengrong1"] = "功名利禄马前取，封狼居胥万户侯。",
  ["$tyj_heg__zhengrong2"] = "枭胡首，筑京观，昭万里。",
}

local H = require "packages.ol_hegemony.util"
local U = require "packages.utility.utility"
zhengrong:addEffect(fk.DetermineDamageCaused, {
  anim_type = "offensive",
  events = { fk.DamageCaused },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhengrong.name) and data.to ~= player and
    ((player:usedSkillTimes(zhengrong.name, Player.HistoryTurn) == 0) or player:usedSkillTimes("tyj_heg__hongjv", Player.HistoryTurn) > 0) and
    #data.to:getCardIds('ej') > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = { "tyj_heg__zhengrong_discard" }
    if data.to:canMoveCardsInBoardTo(player, nil) then
      table.insert(choices, 1, "tyj_heg__zhengrong_move")
    end
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = zhengrong.name,
      all_choices = { "tyj_heg__zhengrong_discard", "tyj_heg__zhengrong_move" },
    })
    if choice == "tyj_heg__zhengrong_move" then
      room:askToMoveCardInBoard(player, {
        target_one = data.to,
        target_two = player,
        skill_name = zhengrong.name,
        move_from = data.to,
      })
    else
      local card = room:askToChooseCard(player, {
        target = data.to,
        flag = "ej",
        skill_name = zhengrong.name,
      })
      room:throwCard(card, zhengrong.name, data.to, player)
    end
  end
})

return zhengrong
